﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.master" Inherits="System.Web.Mvc.ViewPage<DCHealthCheck.MvcWeb.Classes.ViewModels.ResultsViewModel>" %>
<%@ Import Namespace="DCHealthCheck.MvcWeb.Classes" %>
<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
    <%:Global.ApplicationName%>::<%:Model.ControllerName%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="infobox">
        <%Html.RenderPartial("DateFilterControl"); %>
            <%Html.RenderPartial("DomainFilterControl"); %>        
            <%Html.RenderPartial("DCNameFilterControl"); %>
            <%Html.RenderPartial("OSVersionFilterControl"); %>
    </div>
    <div id="contents">
        <div id="leftcontainer">
            <%Html.RenderPartial("TableHeader", this.Model); %>
            <%Html.RenderPartial("ResultsTable"); %>
        </div>
    </div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptsSection" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {

        });
        function deleteResult(id, name) {
            jConfirm('Delete result for: "' + name + '" from database?', 'Please Confirm', function (result) {
                if (result) {
                    $.blockUI({ message: '<br /><img src="../images/loadingAnimation.gif" /><h2> Please wait...</h2>', fadeIn: 500 });
                    var controller = '/<%:ViewData["routeName"].ToString() %>';
                    var dataString = 'Id=' + id;
                    $.ajax({
                        type: "POST",
                        url: controller + "/Delete",
                        data: dataString,
                        async: true,
                        timeout: 300000,
                        success: function () {
                            var searchFilter = "deleteResult\\(\\'" + id;
                            $.unblockUI();

                            // fadeTo is non-functional in IE8
                            $("a[onclick*=" + searchFilter + "]").parent().parent()
                            .fadeTo(3000, 0.3, function () {
                                $(this).hide();
                            });

                            $("a[onclick*=" + searchFilter + "]").parent().parent().children().children()
                            .removeAttr("onclick").removeAttr("href");

                            okGrowl("Action Successful", "Test Result deleted");
                        },
                        error: function () {
                            $.unblockUI();
                            jAlert("Action Unsuccessful.  Check the server logs for details.");
                        }
                    });
                }
            });
        }
    </script>
</asp:Content>
